import java.io.File;

public class h_2 {
    public static void main(String[] args) {
        System.out.println(totalFile("d:\\abc"));
    }
    /*4.统计一个文件夹的总大小*/
    public static long totalFile(String file){
        File f=new File(file);
        File[] files = f.listFiles();
        long total=0;
        for (File f1:files
             ) {
            if(f1.isFile()){
                total=total+f1.length();
            }else {
                total=total+totalFile(f1.toString());
            }
        }
        return total;
    }
}
